package com.up360.rapidcalc.aerolite.model
{
    import com.up360.rapidcalc.aerolite.controller.BasicCtrl;
    import com.up360.rapidcalc.aerolite.swc.AeroliteUI;
    import com.up360.rapidcalc.aerolite.util.Dimension;
    
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.geom.Point;
    import flash.text.TextFieldAutoSize;
    import flash.utils.Timer;

    /**
     * @author Tunie
     * @date   May 2, 2013
     * 陨石
     */
    public class Aerolite extends GameElement
    {
        public static const NORMAL:int=1;
        public static const ACTIVE:int=2;
        public static const BLOWUP:int=3;
        
        private var _outSet:Point;
        /**
         *终点 
         */
        public var finish:Point;
        /**
         *速度，包括垂直与水平方向的速度 
         */
        public var speed:Dimension;
        /**
         *撞击时间 
         */
        public var hitTime:Number;
        /**
         *花了多长时间
         */
        public var costedTime:Number;
        
        private var _answer:Subject;
        
        private var _state:int;
        
        private var _ctrl:BasicCtrl;
        
        public function Aerolite()
        {
            costedTime=0;
            speed=new Dimension();
            buttonMode=true;
        }
        
        /**
         *起点 
         */
        public function get outSet():Point
        {
            return _outSet;
        }

        /**
         * @private
         */
        public function set outSet(value:Point):void
        {
            _outSet = value;
            x=_outSet.x;
            y=_outSet.y;
        }

        /**
         *题目答案 
         */
        public function get answer():Subject
        {
            return _answer;
        }

        /**
         * @private
         */
        public function set answer(value:Subject):void
        {
            if(_answer==value) return;
            _answer = value;
            var b_ui:AeroliteUI=_ui as AeroliteUI;
            b_ui.txtAnswer.text=_answer.rightAnswer();
			b_ui.txtAnswer.autoSize=TextFieldAutoSize.CENTER;
        }

        public function set state(value:int):void
        {
            if(value<0||value>3) return;
            if(value==_state) return;
            _state = value;
            var b_ui:MovieClip=_ui as AeroliteUI;
            b_ui.gotoAndStop(_state);
        }

		
		public function get state():int
		{
			return _state;
		}
		
        public function set ctrl(value:BasicCtrl):void
        {
            _ctrl = value;
            _ctrl.target=this;
        }
    
        public function getTopic():String
        {
            return _answer.topic;
        }
        
        

    }
}